﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>计划安排</title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/JqueryPlug/zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.css?v=4.3.0" rel="stylesheet">
    <link href="/CSS/V3/animate.css" rel="stylesheet"> 
    <link href="/CSS/V3/style.css?v=2.2.0" rel="stylesheet">
    <link href="/CSS/V3/BaseClassV3.css" rel="stylesheet" />
    <script src="/Scripts/jquery-1.11.2.min.js"></script> 
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script src="/JqueryPlug/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
    <script src="/JqueryPlug/zTree_v3/js/jquery.ztree.excheck-3.5.min.js"></script> 
    <script>
        var zNodes = null;
        var zTreeObj = null;
        var model = avalon.define({
            $id: "USUERJHAPLIST",
            menutype: "-1",//菜单类型(0:个人日报.-1:"当前部门日报") 
            queryuser: ComFunJS.getnowuser(), 
            username: ComFunJS.getnowuser(), 
            imgurl: "",
            GZtype: "",
            selGZType: "",
            GZTypeData: [],
            CommonData: [],
            TotalCount: 0,
            UserCount: 0,
            selContent: "",
            content: "",
            page: 0,
            AddJHAP: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=JHAP", "添加数据", "1000", "");
            },
            GetJHAPDataList: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETJHAPLIST', { P1: model.GZtype, p: 1, P2: model.content, b: model.menutype, QUSER:  model.queryuser  }, function (resultData) {
                    model.CommonData.clear();
                    model.CommonData = resultData.Result;
                    model.selGZType = model.GZtype;
                    model.selContent = model.content;

                    if (parseInt(resultData.Result1) > 0) {
                        $("#pageDiv").show();
                        laypage({
                            cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                            pages: parseInt(resultData.Result1), //通过后台拿到的总页数
                            curr: 1, //初始化当前页
                            jump: function (e) { //触发分页后的回调
                                if (model.selGZType != model.GZtype || model.selContent != model.content) {
                                    e.curr = 1;
                                }
                                $.getJSON('/API/FTAPI.ashx?Action=GETJHAPLIST', { P1: model.GZtype, p: e.curr, P2: model.content, b: model.menutype, QUSER:  model.queryuser  }, function (resultData) {
                                    model.CommonData.clear();
                                    model.CommonData = resultData.Result;
                                    model.selGZType = model.GZtype;
                                    model.selContent = model.content;
                                })
                            }
                        });
                    }
                    else {
                        $("#pageDiv").hide();
                    }
                })
            },
            GetGZType: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETCOLUMNLIST', { P1: 12 }, function (resultData) {//计划类型
                    if (resultData.ErrorMsg == "") {
                        model.GZTypeData = resultData.Result;
                        model.GetJHAPDataList();
                    }
                })
            },
            DELJHAP: function (item) {
                parent.ComFunJS.winconfirm("确认要删除么", function () {

                    $.post('/API/FTAPI.ashx?Action=DELJHAPBYID', { "P1": item.ID }, function (result) {
                        result = JSON.parse(result)
                        if (result.ErrorMsg == "") {
                            parent.ComFunJS.winsuccess("删除成功");
                            model.CommonData.remove(item);
                        } else {
                            parent.ComFunJS.winwarning(result.ErrorMsg);
                        }
                    })
                }, function () { })
            },
            EDITJHAP: function (ID) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=JHAP&FrameName=frameJHAP&ID=" + ID, "修改数据", "1000", "");
            },
            AddPL: function (item, dom) {
                var plcontent = dom.val();
                if ($.trim(plcontent) == "") {
                    parent.ComFunJS.winwarning("请输入批注内容");
                    return;
                }
                $.post('/API/FTAPI.ashx?Action=ADDCOMENT', { "P1": plcontent, "MsgType": "JHAP", "MsgLYID": item.ID }, function (result) {
                    var result = $.parseJSON(result);
                    if (result.ErrorMsg == "") {
                        item.PLList.push(result.Result)
                        dom.val("")
                    }
                })
            },
            jptj: function (event, item, dom) {
                if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {
                    model.AddPL(item, dom);
                }
            },
            LB: function () {
                model.GZtype = $(this).attr("vl");
                if ($(this).hasClass("btn-primary")) {
                    model.GetJHAPDataList()
                }
                else {
                    $(".leibie").removeClass("btn-primary");
                    $(".leibie").addClass("btn-white");
                    $(this).removeClass("btn-white");
                    $(this).addClass("btn-primary");
                    model.GetJHAPDataList()
                }
            },
            YC: function () {
                var obj = $(this).parent().parent().find(".social-footer");
                if (obj.is(":hidden")) {
                    obj.show();
                }
                else {
                    obj.hide();
                }
            },
            GuanZhuList: [],
            //关注用户列表
            GetGuanZhuList: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETGUANZHULIST', function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.GuanZhuList = resultData.Result;
                    }
                })
            },
            PL: function (plel) {
                parent.ComFunJS.winbtnwin("/ViewV3/APPBaseView/APP_COMMENT.html?ID=" + plel.ID + "&Type=JHAP&UserName=" + plel.CRUser + "&r=" + Math.random(), "评论", 600, 400, {}, function (layero, index) {
                    var frameid = $("iframe", $(layero)).attr('id');
                    var plnr = parent.window.frames[frameid].getpl();

                    if (plnr.ID) {
                        plel.PLList.push(plnr);
                        parent.ComFunJS.winsuccess("评论成功");
                        parent.layer.close(index);
                    }
                    //else {
                    //    parent.ComFunJS.winwarning("评论失败");
                    //}

                })
            }, fnqueryuser: function (item) {
                if (item) {
                    model.queryuser = item; //item.UserName;
                    model.CommonData.clear();
                    model.page = 0;
                    model.GetJHAPDataList();
                }

            }, GuanZhuData: function () {
                var userNames = "";
                if (model.GuanZhuList) {
                    model.GuanZhuList.forEach(function (val) {
                        userNames += val.BGZUser + ",";
                    })
                }
                if (userNames) {
                    userNames = userNames.substring(0, userNames.length - 1);
                }
                model.fnqueryuser(userNames);
            },
            IsShowTR: false,
            getMenu: function () {
            var setting = {
                data: {
                    simpleData: {
                        enable: true,
                        idKey: "id",
                        pIdKey: "pId",
                        rootPId: 0
                    }
                },
                view: {
                    showLine: false
                },
                callback: {
                    onClick: model.zTreeOnClick
                }
            };
            $.ajax({
                type: "GET",
                url: "/API/SZHLAPI.ashx",
                dataType: "html",
                data: { "Action": "GETALLBMUSERLIST" },
                success: function (msg) {
                    if (JSON.parse(msg).Result) {
                        model.IsShowTR = true;
                    }
                    zTreeObj = $.fn.zTree.init($("#tree"), setting, eval(JSON.parse(msg).Result));
                }
            });
        },
        zTreeOnClick: function (event, treeId, treeNode) {
            model.queryuser = "";
            model.CommonData.clear();
            model.page = 0;
            if (treeNode.isUser) {
                model.queryuser = treeNode.id;
            } else { 
                model.menutype = treeNode.id;
                if (treeNode.children.length > 0 && treeNode.children[0].isUser) {

                    $(treeNode.children).each(function (i, user) {
                        model.queryuser += user.id + ",";
                    })
                    model.queryuser = model.queryuser.substring(0, model.queryuser.length - 1); 
                } 
            }
            model.GetJHAPDataList();
        }
            

        });
        avalon.ready(function () {
            ComFunJS.initsetajax();
            model.getMenu();
            model.GetGuanZhuList();
            $.post("/API/SZHLAPI.ashx?Action=GetUserInfo&r=" + Math.random(), {}, function (data) {

                var data = $.parseJSON(data);
                if (data.ErrorMsg == "") {
                    if (data.Result.QYinfo.FileServerUrl) {
                        var str = data.Result.QYinfo.FileServerUrl;
                        if (str.substr(str.length - 1, 1) != "/") {
                            str = str + "/";
                        }
                        model.imgurl = str;
                    }
                }
                model.GetGZType();
            })
        })

        function pjpf(pllist) {
            var zpf = 0;
            var zrs = 0;
            var pjf = 0;
            if (pllist.length > 0) {
                for (var i = 0; i < pllist.length; i++) {
                    if (pllist[i].Points && pllist[i].Points != "0") {
                        zpf = zpf + pllist[i].Points * 1;
                        zrs = zrs + 1;
                    }
                }

                if (zpf == 0) {
                    return '';
                }
                pjf = zpf / zrs;
                return '<span>评分：</span>' + Math.round(pjf) + ' ' + pf(pjf);
            }
        }

        function pf(str) {
            var on = '<img  src="/JqueryPlug/raty/images/star-on.png" style="width:16px;  margin-right: 0;">&nbsp;';
            var half = '<img  src="/JqueryPlug/raty/images/star-half.png" style="width:16px;  margin-right: 0;">&nbsp;';
            var off = '<img  src="/JqueryPlug/raty/images/star-off.png" style="width:16px;  margin-right: 0;">&nbsp;';
            if (str && str != "0") {

                var html = '';
                var n = parseInt(str / 20);
                var m = Math.ceil(str / 20);
                for (var i = 0; i < n; i++) {
                    html = html + on;
                }
                if (m > n) {
                    html = html + half;
                    n = n + 1;
                }
                for (var j = 0; j < 5 - n; j++) {
                    html = html + off;
                }

                return html;
            }
        }
    </script>
</head>
<body class="gray-bg" ms-controller="USUERJHAPLIST">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="file-manager">
                            <div class="hr-line-dashed"></div>
                            <button class="btn btn-primary btn-block" ms-click="AddJHAP()">添加计划</button>
                            <div class="hr-line-dashed"></div>
                            <h4>类型</h4>
                            <button class="btn btn-primary btn-sm leibie" ms-attr-vl="" ms-click="LB()" type="button">全部</button>
                            <button class="btn btn-white btn-sm leibie" ms-repeat-item="GZTypeData" ms-click="LB()" ms-attr-vl="item.TypeNO" type="button" style="margin-right:5px">{{item.TypeNO}}</button>
                            <div class="hr-line-dashed"></div> 
                            <h4 class="tag-title"><a href="APP_JHAP.html">我的计划</a></h4>
                            <h4 class="tag-title" ms-if="GuanZhuList.size()>0" ms-click="GuanZhuData()"><a>我的关注</a></h4>
                            <ul class="tag-list" style="padding: 0">
                                <li ms-repeat-item="GuanZhuList" ms-click="fnqueryuser(item.BGZUser)">
                                    <button class="btn btn-outline " style="margin-right:5px;" ms-class-1="btn-default:item.BGZUser!=queryuser" ms-class-2="btn-warning:item.BGZUser== queryuser">{{ComFunJS.convertuser(item.BGZUser)}}</button>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                            <h4 class="tag-title" ms-if="model.IsShowTR">他人计划</h4>
                          
                             <ul id="tree" ms-if="model.IsShowTR" class="ztree"></ul>
                                 
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9">
                <div class="ibox">
                    <div class="box" style="margin-bottom:15px;">
                        <div class="pull-right mail-search">
                            <div class="input-group">
                                <input type="text" class="form-control input-sm" ms-duplex="content" name="search" placeholder="输入计划内容查询">
                                <div class="input-group-btn">
                                    <button type="submit" class="btn btn-sm btn-primary" ms-click="GetJHAPDataList()">
                                        搜索
                                    </button>
                                </div>
                            </div>
                        </div>
                        <h2>
                            计划安排
                        </h2>
                        <div class="mail-tools tooltip-demo m-t-md">
                            <div class="btn-group pull-right">
                                <div id="pageDiv" class="text-center"></div>
                            </div>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    <div class="social-feed-separated" ms-repeat-item="CommonData">
                        <div class="social-avatar" style="text-align:center;width:52px">
                            <a>
                                <img alt="image" ms-attr-src="'/Upload/TX/'+item.CRUser+'.jpg'" onerror="javascript: this.src = '/images/TX/default.png'" style="border:0">
                            </a>
                            <br />
                            <span style="line-height: 30px;">{{ComFunJS.convertuser(item.CRUser) }}</span>
                        </div>
                        <div class="social-feed-box" style="margin-left:62px">
                            <div class="pull-right social-action dropdown">
                                <a class=" btn btn-primary btn-xs btntool" ms-if="item.CRUser==username" ms-click="EDITJHAP(item.ID)"><i class="fa fa-pencil"></i> 编辑 </a>
                                <a class="btn btn-danger btn-xs btntool" style="margin-right:15px" ms-if="item.CRUser==username" ms-click="DELJHAP(item)"><i class="fa fa-trash-o"></i> 删除 </a>
                                <a class="btn btn-white btn-xs " ms-click="YC()"><i class="fa fa-angle-down"></i> </a>
                            </div>
                            <div class="social-avatar" style="line-height: 23px;">
                                <label class="label label-info" style="margin-right:10px">{{item.LeiBie}}</label>
                                <small><span class="text-danger">{{item.RBDate|date("yyyy年MM月dd日")}}</span></small>
                            </div>
                            <div class="social-body">
                                <p>
                                    <span style="color: #3085DB;" >计划内容：</span>
                                    <span ms-html="item.RBContent" style="word-break:break-all;" ms-if="item.RBContent!=''"></span>
                                </p>
                                <p ms-if="item.RBWCQK">
                                    <span style="color: #3085DB;">完成情况：</span>
                                    <span ms-html="item.RBWCQK" style="word-break:break-all;"></span>
                                </p>
                            </div>
                            <div class="social-footer">
                                <div class="social-comment" style="padding-bottom:10px;" ms-if="item.FileList.length>0">
                                    <div class="media-body">
                                        <span>附件：</span><!--<a style="padding-right:10px" ms-repeat-files="item.FileList" target="_blank" download="filename" ms-attr-href="'/View/Common/DownLoadFile.aspx?MD5='+files.FileMD5">{{files.Name+'.'+files.FileExtendName}}</a>-->
                                        <a ms-repeat-files="item.FileList" target="_blank" ms-attr-href="imgurl+files.FileMD5">
                                            <img ms-attr-src="imgurl+'image/'+files.FileMD5" ms-if="ComFunJS.xstp(files.FileExtendName)" style="width:100px;height:100px;margin-bottom:10px" />
                                        </a>
                                        <a ms-repeat-fl="item.FileList" target="_blank" ms-attr-href="imgurl+fl.FileMD5">
                                            <img ms-attr-src="'/images/NewIndex/qywd/'+fl.FileExtendName+'.png'" ms-if="!ComFunJS.xstp(fl.FileExtendName)" style="width:100px;height:100px;margin-bottom:10px" />
                                        </a>
                                    </div>
                                </div>
                                <div class="social-comment">
                                    <div class="media-body">

                                        {{pjpf(item.PLList)|html}}
                                    </div>
                                </div>
                                <div class="social-comment" ms-repeat-el="item.PLList">
                                    <span class="pull-left">
                                        <img alt="image" ms-attr-src="'/Upload/TX/'+el.CRUser+'.jpg'" onerror="javascript: this.src = '/images/TX/default.png'">
                                    </span>
                                    <div class="media-body">
                                        <span style="color: #3085DB;">
                                            {{el.CRUserName}}
                                        </span> {{el.MSGContent}}

                                        <br />{{pf(el.Points)|html}} -
                                        <small class="text-muted">{{el.CRDate|date("MM月dd日 HH:mm")}}</small>
                                    </div>
                                </div>
                                <div class="social-comment">
                                    <button type="button" class="btn btn-xs btn-primary " ms-click="PL(item)">  添加评论</button>
                                    <!--<span class="pull-left">
                                        <img alt="image" src="/images/TX/default.png">
                                    </span>
                                    <div class="media-body">
                                        <div class="input-group">
                                            <input type="text" class="form-control" ms-keypress="jptj(event,item,$(this))" placeholder="填写评论(按Ctrl+Enter直接提交)" />
                                            <span class="input-group-btn">
                                                <button type="button" class="btn btn btn-primary addTL" autocomplete="off" ms-on-click="AddPL(item,$(this).parent().parent().find('input'))">  添加评论</button>
                                            </span>
                                        </div>
                                    </div>-->
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</body>
</html>
